package com.example.xlzx.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xlzx.entity.AboutUs;
import com.example.xlzx.entity.User;
import com.example.xlzx.result.Result;
import com.example.xlzx.service.IAboutUsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 关于我们表 前端控制器
 * </p>
 *
 *
 * @since 2025-03-07
 */
@RestController
@Tag(name="关于我们")
@RequestMapping("/xlzx")
public class AboutUsController {
    @Autowired
    private IAboutUsService aboutUsService;
    @Operation(summary = "新增关于我们")
    @PostMapping("/insetAboutUs")
    public Result<Boolean> insertAboutUs(@RequestBody AboutUs aboutUs) {
        return Result.ok(aboutUsService.save(aboutUs));
    }

    @Operation(summary = "根据id删除关于我们")
    @DeleteMapping("/deleteAboutUs/{id}")
    public Result<Boolean> deleteUser(@PathVariable Long id) {
        return Result.ok(aboutUsService.removeById(id));
    }

    @Operation(summary = "修改关于我们信息")
    @PutMapping("/updateAboutUs")
    public Result<Boolean> updateAboutUs(@RequestBody AboutUs aboutUs) {
        return Result.ok(aboutUsService.updateById(aboutUs));
    }

    @Operation(summary = "根据id查询关于我们信息")
    @GetMapping("/getAboutUsInfo/{id}")
    public Result<AboutUs> getUserInfo(@PathVariable Long id) {
        return Result.ok(aboutUsService.getById(id));
    }

    @Operation(summary = "关于我们分页查询")
    @GetMapping("/selectAboutUs/page")
    public Result<Page<AboutUs>> selectAboutUs(  @RequestParam int page, @RequestParam int size) {
        Page<AboutUs> pageParam = new Page<>(page, size);

        return Result.ok(aboutUsService.page(pageParam));
    }

}
